class Matrix {

    private int rowCount;
    private int columnsCount;
    private String[][] matrix;

    Matrix(String matrixAsString) {
        String[] matrixSplit = matrixAsString.split("\n");
        this.matrix = new String[matrixSplit.length][];

        for (int i = 0; i < this.matrix.length; i++) {
            this.matrix[i] = matrixSplit[i].split("");

            if (this.matrix[i].length > this.columnsCount)
                this.columnsCount = this.matrix[i].length;

            this.rowCount++;
        }
    }

    int getRowsCount() {
        return this.rowCount;
    }

    int getColumnsCount() {
        return this.columnsCount;
    }

    int[] getRow(int i) {
        int[] row = new int[this.rowCount];

        for (int j = 0; j < row.length; j++) {
            row[j] = Integer.valueOf(this.matrix[i][j]);
        }
        return row;
    }

    int[] getColumn(int i) {
        int[] col = new int[this.columnsCount];

        for (int j = 0; j < this.rowCount; j++) {
            col[j] = Integer.valueOf(this.matrix[j][i]);
        }
        return col;
    }
}